package 第2节数组;

import java.util.Scanner;

public class LianXi02 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int row = input.nextInt();
        int col = input.nextInt();
        int target = input.nextInt();
        int[][] matrix = new int[row][col];
        for (int i = 0; i < row; i++) {
            for (int j = 0;j < col; j++) {
                matrix[i][j] = input.nextInt();
            }
        }
        //O(log(m*n))
        int low = 0;
        int high = row * col - 1;
        int mid = (low + high) / 2;
        while (matrix[mid / col][ mid % col] != target) {
            if (matrix[mid / col][ mid % col] < target) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
            if (high < low) {
                mid = -1;
                break;
            }
            mid = (low + high) / 2;
        }
        if (mid == -1) {
            System.out.println(false);
        } else {
            System.out.println(true);
        }

    }
}
/*
3 4 12
1 3 5 7
10 11 16 20
23 30 34 60
*/
